using System;
using System.Collections;
using Castle.MonoRail.Framework;
using Castle.MonoRail.Framework.Helpers;

namespace Saffron.Components
{
    
    public class PagingListComponent : ViewComponent
    {
        private IList _list;
        private string _name;

        public override void Initialize()
        {
            _list = (IList) ComponentParams["list"];
            _name = (string) ComponentParams["controller"];

            base.Initialize();
        }

        public override void Render()
        {
            IPaginatedPage page = PaginationHelper.CreatePagination(_list, 20, 0);

            PropertyBag["page"] = page;
            PropertyBag["controller"] = _name;

            base.Render();
        }

        public override bool SupportsSection(string name)
        {
            return base.SupportsSection(name);
        }
    }
}
